package com.passengerflowmanagementsystem.web.controller.em;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.passengerflowmanagementsystem.common.annotation.Log;
import com.passengerflowmanagementsystem.common.core.controller.BaseController;
import com.passengerflowmanagementsystem.common.core.domain.AjaxResult;
import com.passengerflowmanagementsystem.common.enums.BusinessType;
import com.passengerflowmanagementsystem.statistics.domain.EmExhibitionCabinet;
import com.passengerflowmanagementsystem.statistics.service.IEmExhibitionCabinetService;
import com.passengerflowmanagementsystem.common.utils.poi.ExcelUtil;
import com.passengerflowmanagementsystem.common.core.page.TableDataInfo;

/**
 * 展柜Controller
 * 
 * @author sheng
 * @date 2024-10-28
 */
@RestController
@RequestMapping("/em/cabinet")
public class EmExhibitionCabinetController extends BaseController
{
    @Autowired
    private IEmExhibitionCabinetService emExhibitionCabinetService;

    /**
     * 查询展柜列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EmExhibitionCabinet emExhibitionCabinet)
    {
        startPage();
        List<EmExhibitionCabinet> list = emExhibitionCabinetService.selectEmExhibitionCabinetList(emExhibitionCabinet);
        return getDataTable(list);
    }

    /**
     * 导出展柜列表
     */
    @Log(title = "【导出展柜列表】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmExhibitionCabinet emExhibitionCabinet)
    {
        List<EmExhibitionCabinet> list = emExhibitionCabinetService.selectEmExhibitionCabinetList(emExhibitionCabinet);
        ExcelUtil<EmExhibitionCabinet> util = new ExcelUtil<EmExhibitionCabinet>(EmExhibitionCabinet.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取展柜详细信息
     */
    @GetMapping(value = "/{cabinetId}")
    public AjaxResult getInfo(@PathVariable("cabinetId") Long cabinetId)
    {
        return success(emExhibitionCabinetService.selectEmExhibitionCabinetByCabinetId(cabinetId));
    }

    /**
     * 新增展柜
     */
    @Log(title = "【新增展柜】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmExhibitionCabinet emExhibitionCabinet)
    {
        return toAjax(emExhibitionCabinetService.insertEmExhibitionCabinet(emExhibitionCabinet));
    }

    /**
     * 修改展柜
     */
    @Log(title = "【修改展柜】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmExhibitionCabinet emExhibitionCabinet)
    {
        return toAjax(emExhibitionCabinetService.updateEmExhibitionCabinet(emExhibitionCabinet));
    }

    /**
     * 删除展柜
     */
    @Log(title = "【删除展柜】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cabinetIds}")
    public AjaxResult remove(@PathVariable Long[] cabinetIds)
    {
        return toAjax(emExhibitionCabinetService.deleteEmExhibitionCabinetByCabinetIds(cabinetIds));
    }
}
